import 'package:flutter/material.dart';

class Home extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("PageView Demo"),
      ),
      body: TabbarViewDemo(),
    );
  }
}

class TabbarViewDemo extends StatefulWidget {
  @override
  State<StatefulWidget> createState() => TabbarViewPage();
}

class TabbarViewPage extends State<TabbarViewDemo> {
  @override
  Widget build(BuildContext context) {
    List _tabs = ["快讯", "大事件", "头条", "我的"];

    return DefaultTabController(
      length: _tabs.length,
      child: Column(
        children: [
          Container(
            height: 40,
            child: TabBar(tabs: _tabs.map((e) => Tab(text: e,)).toList(), labelColor:Colors.black, indicatorSize: TabBarIndicatorSize.label,),
          ),
          
          Container(
          height: 500,
          child:  TabBarView(
          children: _tabs.map((e) {
            return Center(
              child: Text(e),
            );
          }).toList(),
        )
        
      ),


        ],
      
      ),
    );
  }
}
